import 'package:flutter/material.dart';
import 'package:delivery_application/common/globs.dart';
import 'package:delivery_application/common/service_call.dart';
import 'package:delivery_application/view/home/home_page.dart';
import 'package:delivery_application/view/login/welcome_view.dart';

class StartupView extends StatefulWidget {
  const StartupView({super.key});

  @override
  State<StartupView> createState() => _StarupViewState();
}

class _StarupViewState extends State<StartupView> {
  //startup——view显示2秒之后出现welcome_view
  @override
  void initState() {
    super.initState();
    goWelcomePage();
  }

  //startup——view显示2秒之后出现welcome_view
  void goWelcomePage() async {
    await Future.delayed(const Duration(seconds: 2));
    if (mounted) {
      Navigator.pushReplacement(
        context, 
        MaterialPageRoute(builder: (context) => const WelcomeView())
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    var media = MediaQuery.of(context).size;

    return Scaffold(
      body: Stack(
        alignment: Alignment.center,
        children: [
          //首页背景图
          Image.asset(
            "assets/img/background2.png",
            width: media.width,
            height: media.height,
            fit: BoxFit.cover,
          ),
          //首页logo
          Positioned(
            bottom: media.height * 0, //改变logo位置使其位于页面下方
            child: Image.asset(
              "assets/img/uavlogo.png",
              width: media.width * 0.5,
              height: media.height * 0.5,
              fit: BoxFit.contain,
            ),
          ),
        ],
      ),
    );
  }
}
